# -*- coding: utf-8 -*-
import scrapy
from baidu.items import TextItem


class Exercise1Spider(scrapy.Spider):
    name = 'exercise1'
    allowed_domains = ['forali.club']
    start_urls = ['http://forali.club/']

    def parse(self, response):
        titlt_list = response.xpath('//*[@id="posts"]/article/div/header/h1/a/text()').extract()
        date_list = response.xpath('//*[@id="posts"]/article/div/header/div/span[1]/time/text()').extract()
        for i in range(len(titlt_list)):
            item = TextItem()
            item['title'] = titlt_list[i]
            item['date'] = date_list[i].replace(' ', '').replace('\n', '')
            yield item
